/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package rmiserver;

import dbwrapper.DbQuery;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.ArrayList;
import java.util.Date;


/**
 * Реализация удаленного интерфейса
 * @author alexxxey
 */
public class TicketServiceImpl extends UnicastRemoteObject implements TicketService
{    
    public TicketServiceImpl() throws RemoteException
    {
        
    }
        
    @Override
    public ArrayList<Trip> getAllTrips() throws RemoteException        
    {                                    
        return DbQuery.getAllTripsQuery();
    }

    @Override
    public ArrayList<Trip> findTrip(String targetPlace) throws RemoteException
    {                                     
        return DbQuery.findTripsQuery(targetPlace);
    }
   
    @Override
    public ArrayList<Trip> findTrip(Date tripDate) throws RemoteException
    {        
        return DbQuery.findTripsQuery(tripDate); 
    }

    @Override
    public ArrayList<Integer> getPlaces(int tripId) throws RemoteException
    {        
        return DbQuery.tripPlacesQuery(tripId);
    }

    @Override
    public void reserveTicket(Ticket ticket) throws RemoteException
    {
        DbQuery.insertTicketQuery(ticket);        
    }

    @Override
    public ArrayList<Ticket> getReservedTickets(int manId) throws RemoteException
    {
        return DbQuery.getReservedTickets(manId);
    }

    @Override
    public void cancelReserveTicket(Ticket ticket) throws RemoteException
    {
        DbQuery.removeTicketQuery(ticket);
    }
    
       
}
